<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="admin/inc/conn.inc"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>生成Wiki</title>
</head>

<body>
<%
	Id = SelfRequestNumber("id")
	if Id <> "" Then
		strTitle = SelfRequestString("title")
		strText = SelfRequestString("text")
		if strTitle <> "" and strText <> "" Then
			strText = replace(strText,Chr(13),"<br />") 
			strText = replace(strText,Chr(10),"") 
			strHtml = "<div class=""TableRow"" align=""left""><div class=""WikiUser""><a href=""http://www.77go.cn/userInfo.bbscs?t=name&username=$Username$"" target=""_blank"">$Nickname$</a></div><div class=""WikiTitle"">$Title$</div><div class=""WikiText"">$Text$</div></div>"
			strHtml = replace(strHtml, "$Username$", session("Username"))
			if session("Nickname") <> "" then
				strHtml = replace(strHtml, "$Nickname$", session("Nickname"))
			else
				strHtml = replace(strHtml, "$Nickname$", "游客")
			end if
			strHtml = replace(strHtml, "$Title$", strTitle)
			strHtml = replace(strHtml, "$Text$", strText)
		
			strSql = "select * from GameWikiBoard"
			Set rs = Server.CreateObject("ADODB.Recordset")
			rs.Open strSql,dbconnection,1,3
			rs.addnew
			rs("BoardID") = Id
			rs("Nickname") = session("Nickname")
			rs("Username") = session("Username")
			rs("Password") = session("Password")
			rs("Title") = strTitle
			rs("Text") = strText		
			rs("Html") = strHtml		
			rs.update
		end if 		
		
		strHtml = ""
		strSql = "select Html from GameWikiBoard where BoardID=" & Id &" order by id desc"
		Set rs = Server.CreateObject("ADODB.Recordset")
		rs.Open strSql,dbconnection,1,3
		
		do while not rs.Eof
			strHtml = strHtml & rs("Html")
			rs.movenext
		loop

	
		strSql = "select * from GameWiki where ID=" & Id
		Set rs = Server.CreateObject("ADODB.Recordset")
		rs.Open strSQL, dbconnection, adOpenDynamic, 3
		if(rs.Eof) then
			response.Write("Id 出错")
			response.end		
		else
			Const ForReading = 1, ForWriting = 2   
			Dim fso, f   
			Set fso = CreateObject("Scripting.FileSystemObject")   
			Set f = fso.OpenTextFile(server.mappath("wikivip\Framework.htm"), ForReading)
			ReadAllTextFile = f.ReadAll   
			ReadAllTextFile = replace(ReadAllTextFile,"$ID$",rs("ID")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Hot$",rs("Hot")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Click$",rs("Click")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Name$",rs("Name")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Gamer$",rs("Gamer")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Title$",rs("Title")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Text$",rs("Text")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$Pic$",rs("Pic")) 
			ReadAllTextFile = replace(ReadAllTextFile,"$board$", strHtml)
			
			Dim objTypeLib
			Set objTypeLib = CreateObject("Scriptlet.TypeLib")
			strURL = objTypeLib.Guid
			strURL = Mid(strURL, 1, Len(strURL) - 2)
			rs("URL") = strURL
			rs.update
		
			Set f =  fso.OpenTextFile(server.mappath("wikivip\" & rs("URL") & ".htm"), ForWriting, True)   
			f.Write ReadAllTextFile
			Response.Write("<meta HTTP-EQUIV=REFRESH CONTENT='1; URL=/wikivip/"&rs("URL")&".htm'>生成成功，一秒钟后自动返回")
		end if
		set rs = nothing
	else
		response.Write("Id 出错")
		response.end	
	end if	
%>
</body>
</html>
<!--#include file="disconn.inc"-->